<?php
namespace Admin\Controller;
use  Think\Controller;
class LoginController extends Controller{
	//生成验证码
	public function checkcode(){
		$config =    array( 
	   'fontSize'    =>    30,   
	   'length'      =>    3,      
	   'useNoise'    =>    false, );//关闭渣点
		$Verify =     new \Think\Verify($config);
		$Verify->entry();
	}
	public function login(){
		if(IS_POST){
			$model = D('Admin');
		
			//接收表单信息 并验证规则
			if($model->validate($model->_login_validate)->create()){
				//var_dump(I('post.'));die();
				if($model->login()){
					$this->success('恭喜登錄成功',U('Admin/Index/index'));
					exit;
				}
			}
			$error = $model->getError();
			$this->error($error);
			
		}
		
		$this->display();
		
	}
}